home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Language/OS - Multiplatform Resource Library
/
LANGUAGE OS.iso
/
pcr
/
pcr4_4.lha
/
DIST
/
debugnub
/
CedarCirioNubProcs.c
< prev
next >
Wrap
C/C++ Source or Header
|
1992-04-16
|
9KB
|
309 lines
/* begincopyright
Copyright (c) 1988-1992 Xerox Corporation. All rights reserved.
Use and copying of this software and preparation of derivative works based
upon this software are permitted. Any distribution of this software or
derivative works must comply with all applicable United States export
control laws. This software is made available AS IS, and Xerox Corporation
makes no warranty about the software, its performance or its conformity to
any specification. Any person obtaining a copy of this software is requested
to send their name and post office or electronic mail address to:
PCR Coordinator
Xerox PARC
3333 Coyote Hill Rd.
Palo Alto, CA 94304
endcopyright */
/*
* CedarCirioNubProcs.c
*
* A collection of procs to examine Cedar Typecodes
*
* Demers, March 3, 1992 5:09:57 pm PST
*/
#define CCNP_DEBUG 1
#define DYNAMIC_C_LOOKUP 0
/* #include "xr/CirioNubProtocol.h" */
#include "xr/CirioNubMarshall.h"
#include "xr/CedarCirioNubProcs.h"
/* #include "xr/CirioNubEnvironment.h" */
#include "xr/CirioNubInstall.h"
#if DYNAMIC_C_LOOKUP
# include "xr/IncrementalLoad.h"
#endif
#if CCNP_DEBUG
# include "xr/ThreadsMsg.h" /* for XR_ConsoleMsg debug msgs */
#endif
/*
* The following two utilities are stolen directly from Interp.c ...
* call from thread only.
*/
#if DYNAMIC_C_LOOKUP
int
CedarCirioNubLookupCProc(name, valp)
char *name;
unsigned *valp;
{
XR_ILSymEntry ilse;
char *altText;
ilse = XR_ILGetMatchingSymEntryByName(
NIL, name, TRUE, WANT_ALL_TYPES, IGNORE_INTERNAL, 0 );
if( ilse == NIL ) {
ilse = XR_ILGetMatchingSymEntryByName(
NIL, name, TRUE, WANT_ALL_TYPES, IGNORE_NONE, 0 );
}
if( (ilse == NIL) && (name[0] != '_') ) {
altText = (char *)XR_malloc(2+strlen(name));
altText[0] = '_'; (void)strcpy(&(altText[1]), name);
ilse = XR_ILGetMatchingSymEntryByName(
NIL, altText, TRUE, WANT_ALL_TYPES, IGNORE_INTERNAL, 0 );
if( ilse == NIL ) {
ilse = XR_ILGetMatchingSymEntryByName(
NIL, altText, TRUE, WANT_ALL_TYPES, IGNORE_NONE, 0 );
}
}
if( ilse == NIL ) {
return (-1);
}
*valp = ((unsigned)(ilse->ilse_value));
return 0;
}
#endif
int
CedarCirioNubLookupCedarProc(interfaceName, procName, procp)
char *interfaceName;
char *procName;
XR_MesaProc *procp;
{
static XR_MesaProc ((*procFromNamedInterface)()) = NIL;
int ans;
char *tailP, *dotP;
XR_MesaProc cedarProcValue;
# if CCNP_DEBUG
XR_ConsoleMsg("CirioNubBinding to %s %s ... ", interfaceName, procName);
# endif
if( (interfaceName == NIL) || (procName == NIL) ) return (-1);
# if DYNAMIC_C_LOOKUP
if( procFromNamedInterface == NIL ) {
ans = CedarCirioNubLookupCProc( "XR_ProcFromNamedInterface",
&procFromNamedInterface );
if( ans < 0 ) return ans;
}
# else
{
extern XR_MesaProc XR_ProcFromNamedInterface();
procFromNamedInterface = XR_ProcFromNamedInterface;
}
# endif
cedarProcValue = (*procFromNamedInterface)(interfaceName, procName, NIL, 0);
# if CCNP_DEBUG
XR_ConsoleMsg("result 0x%x ", cedarProcValue);
if( cedarProcValue ) XR_ConsoleMsg( "(0x%x 0x%x)",
cedarProcValue->mp_proc, cedarProcValue->mp_x );
XR_ConsoleMsg("\n");
# endif
if( cedarProcValue == NIL ) {
return(-1);
}
(*procp) = cedarProcValue;
return 0;
}
/*
* Binding to MesaLoadState ...
*
* This initialization must be called from a thread before the debug nub
* starts running in its slave IOP.
*/
static XR_MesaProc mpGetTypestring = NIL;
static XR_MesaProc mpGetTypecode = NIL;
static XR_MesaProc mpGetConcreteTypecode = NIL;
static void
CedarCirioNubBindToLoadStateProcs()
{
(void)CedarCirioNubLookupCedarProc(
"MesaLoadStateBackdoor", "UnmonitoredTypeStringFromType",
&mpGetTypestring );
(void)CedarCirioNubLookupCedarProc(
"MesaLoadStateBackdoor", "UnmonitoredFindTypeFromTypeString",
&mpGetTypecode );
(void)CedarCirioNubLookupCedarProc(
"MesaLoadState", "ConcreteTypeFromAbstractType",
&mpGetConcreteTypecode );
}
/*
* Exported Cirio Nub Procs ...
*/
#define MESA_STRING_MAXLEN 4000
typedef struct MesaStringRep {
unsigned short ms_len;
unsigned short ms_maxLen;
char ms_data[MESA_STRING_MAXLEN];
} * MesaString;
CirioNubRetCode
CedarCirioNubServeGetTypestring(argc, args)
int argc;
unsigned *args;
{
XR_MesaProc mp = mpGetTypestring;
int ans;
CirioNubRetCode rc;
struct CirioNubCedarTypeCodeRep tc;
MesaString ms;
# if CCNP_DEBUG
XR_ConsoleMsg("CirioNub GetTypestring argc %d\n", argc);
# endif
if( argc != 1 ) return( cnrc_badArgs );
tc.typeCode = (unsigned long)(args[0]);
if( mp == NIL ) return cnrc_noProc;
ms = (MesaString) ((*(mp->mp_proc))(tc.typeCode, mp));
if( ms == NIL ) {
# if CCNP_DEBUG
XR_ConsoleMsg("GetTypestring fails ms == NIL\n");
# endif
return cnrc_badArgs; /* ??? */
}
# if CCNP_DEBUG
XR_ConsoleMsg("GetTypestring res len %d\n", ms->ms_len);
# endif
if( (rc = CirioNubPutBlock8(ms->ms_data, ms->ms_len)) != cnrc_ok )
return rc;
return cnrc_ok;
}
CirioNubRetCode
CedarCirioNubServeGetTypecode(argc, args)
int argc;
unsigned *args;
{
int ans, len;
CirioNubRetCode rc;
XR_MesaProc mp = mpGetTypecode;
struct {
long fnd;
struct CirioNubCedarTypeCodeRep tc;
} resultRec;
struct MesaStringRep ms;
# if CCNP_DEBUG
XR_ConsoleMsg("CirioNub GetTypecode argc %d ", argc);
if( argc >= 1 ) XR_ConsoleMsg("len %d", (int)(args[0]));
XR_ConsoleMsg("\n");
# endif
if( argc != 2 ) return cnrc_badArgs;
len = (int)(args[0]);
if( len > MESA_STRING_MAXLEN ) return cnrc_badArgs;
ms.ms_len = len;
ms.ms_maxLen = MESA_STRING_MAXLEN;
bcopy( (char *)(args[1]), ms.ms_data, len);
if( mp == NIL ) return cnrc_noProc;
(*(mp->mp_proc))(&resultRec, &ms, mp);
# if CCNP_DEBUG
XR_ConsoleMsg("CirioNub GetTypecode res %d 0x%x\n",
resultRec.fnd, resultRec.tc.typeCode );
# endif
if( (rc = CirioNubPutCard32(resultRec.fnd)) != cnrc_ok ) return rc;
if( (rc = CirioNubPutCard32(resultRec.tc.typeCode)) != cnrc_ok ) return rc;
return cnrc_ok;
}
CirioNubRetCode
CedarCirioNubServeGetConcreteTypecode(argc, args)
int argc;
unsigned *args;
{
XR_MesaProc mp = mpGetConcreteTypecode;
int ans;
CirioNubRetCode rc;
struct CirioNubCedarTypeCodeRep abs;
struct CirioNubCedarTypeCodeRep conc;
# if CCNP_DEBUG
XR_ConsoleMsg("CirioNub GetConcrete argc %d ", argc);
if( argc >= 1 ) XR_ConsoleMsg("arg 0x%x", args[0]);
XR_ConsoleMsg("\n");
# endif
if( argc != 1 ) return cnrc_badArgs;
abs.typeCode = (unsigned long)(args[0]);
if( mp == NIL ) return cnrc_noProc;
conc.typeCode = (*(mp->mp_proc))(abs.typeCode, mp);
# if CCNP_DEBUG
XR_ConsoleMsg("GetConcrete res 0x%x\n", conc.typeCode);
# endif
if( (rc = CirioNubPutCard32(conc.typeCode)) != cnrc_ok ) return rc;
return cnrc_ok;
}
static CirioNubRetCode
CedarCirioNubServeNull(argc, args)
int argc;
unsigned *args;
{
unsigned v;
CirioNubRetCode rc;
v = ((argc >= 1) ? args[0] : CEDAR_CIRIO_NUB_PROCS_VERSION);
if( v < CEDAR_CIRIO_NUB_PROCS_LOW_VERSION ) {
v = CEDAR_CIRIO_NUB_PROCS_LOW_VERSION;
} else if( v > CEDAR_CIRIO_NUB_PROCS_VERSION ) {
v = CEDAR_CIRIO_NUB_PROCS_VERSION;
}
if( (rc = CirioNubPutCard32(v)) != cnrc_ok ) return rc;
return cnrc_ok;
}
int
XR_run_CedarCirioNub()
{
CirioNubHandle h;
if( (h = CirioNubGetDefaultHandle(0, 0)) == NIL ) return (-1);
CedarCirioNubBindToLoadStateProcs();
(void)CirioNubRegisterCProc(h,
CedarCirioNubProcID_Null,
CedarCirioNubServeNull);
(void)CirioNubRegisterCProc(h,
CedarCirioNubProcID_GetTypestring,
CedarCirioNubServeGetTypestring);
(void)CirioNubRegisterCProc(h,
CedarCirioNubProcID_GetTypecode,
CedarCirioNubServeGetTypecode);
(void)CirioNubRegisterCProc(h,
CedarCirioNubProcID_GetConcreteTypecode,
CedarCirioNubServeGetConcreteTypecode);
return 0;
}